import { decrypt, encryption } from "@/assets/js/http";
import { mapGetters, mapActions } from "vuex";
import _ from "lodash";
import template from "./gameListTemplate";
const { render, staticRenderFns } = template;

export default {
  render,
  staticRenderFns,
  data() {
    return {
      gameList: [],
      showPwdDlg: false,
      lottery_type: 0,
      tip: "",
      showTip: false,
      roomTitle: this.$route.query.type_name,
      notLoginFlag: false,
    };
  },
  mounted() {
    var params = {
      token: localStorage.getItem("token"),
      id: this.$route.query.id,
    };
    this.$http
      .post(this.urlRequest + "?m=api&c=game&a=getGameListForType", {
        id: this.$route.query.id,
      })
      .then((res) => {
        if (res.status == 0) {
          this.gameList = res.list;
          console.log(this.gameList);
        }
        this.$vux.loading.hide();
      });
  },
  created() {
    this.$vux.loading.show();
  },

  computed: {
    ...mapGetters(["accountData"]),
  },
  methods: {
    headBack: function () {
      this.$router.push({
        path: "/home",
      });
    },
    goLogin() {
      this.$router.push({
        path: "/login",
      });
    },
    goGame(id) {
      if (!localStorage.getItem("token")) {
        //未登录状态
        this.notLoginFlag = true;
        return;
      }
      this.$http
        .post(this.urlRequest + "?m=api&c=game&a=getGameUrl", { id: id })
        .then((res) => {
          this.$vux.loading.hide();
          if (res.status == 0) {
            window.location.href = res.data.gameUrl;
          } else {
            this.$vux.toast.show({
              text: res.ret_msg,
            });
          }
        });
    },
  },
};

// WEBPACK FOOTER //
// ./src/components/room/roomList/gameList.vue
